package com.ubaer.zsycz.views;

import android.os.CountDownTimer;

import javax.inject.Inject;

/**
 * author：JiaXing
 * e-mail：JiaXingGoo@gmail.com
 */
public class MyCountDownTimer extends CountDownTimer {

    private OnCountListener listener;

    @Inject
    public MyCountDownTimer(long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
    }

    //计时过程
    @Override
    public void onTick(long l) {
        if (listener != null) listener.onTick(l);
    }

    //计时完毕的方法
    @Override
    public void onFinish() {
        if (listener != null) listener.onFinish();
    }

    public MyCountDownTimer addOnCountListener(OnCountListener listener) {
        this.listener = listener;
        return this;
    }

    public interface OnCountListener {
        void onTick(long l);

        void onFinish();
    }
}
